package middle;

public class Solution_201 {

    public int rangeBitwiseAnd(int left, int right) {
        int count = 0;
        while (left < right) {
            left >>= 1;
            right >>= 1;
            count++;
        }
        return left << count;
    }

    public static void main(String[] args) {
        Solution_201 model = new Solution_201();
        System.out.println(model.rangeBitwiseAnd(3, 4));
        System.out.println(model.rangeBitwiseAnd(5, 7));
        System.out.println(model.rangeBitwiseAnd(10, 30));
        System.out.println(model.rangeBitwiseAnd(12, 38));
        System.out.println(model.rangeBitwiseAnd(2, 20));
        System.out.println(model.rangeBitwiseAnd(1, 2147483647));
    }
}
